package com.dpiinc.TechPage.constants

/**
 * 文件类型
 * Created by X on 2018/7/26.
 */
enum class FileType(val value: Int) {
    UNKNOWN(0),
    DOT_FILE(1),
    AUDIO_FILE(2),
    IMG_FILE(3);

    companion object {
        fun parse(value: Int): FileType {
            return when (value) {
                1 -> DOT_FILE
                2 -> AUDIO_FILE
                3 -> IMG_FILE
                else -> UNKNOWN
            }
        }

        fun parse(extension: String): FileType {
            return when (extension) {
                "txt" -> DOT_FILE
                "mp3" -> AUDIO_FILE
                "png" -> IMG_FILE
                else -> UNKNOWN
            }
        }
    }
}


